package ch.myDungeons.gameObjects;

import ch.myDungeons.characters.Person;

/**
 * An abstract potion class that can be consumed
 * @author Grii
 *
 */
public abstract class Potion extends Item {
	private static final long serialVersionUID = 61370275656240563L;


	public Potion(String itemName) {
		super(itemName);
	}
	
	public void use(Person user){
		
	}
	
	/** returns name, count, itemtype. split at ITEMINFO */
	public String getSave(){
		String result = super.getSave();
		return result;
	}
	
	
	public static class HealthPotion extends Potion {
		private static final long serialVersionUID = 6487568549946063722L;
		
		public int healthRestore = 20;
		
		public HealthPotion(String potionSize) {
			super(potionSize + "health potion");
		}

		public void use(Person user) {
			super.use(user);
			user.setCurrentHP(user.getCurrentHP() + healthRestore);
			if (user.getCurrentHP() >= user.getMaxHP()) {
				user.setCurrentHP(user.getMaxHP());
			}
		}
		
		/** Returns a copy of the item */
		public HealthPotion getCopy() {
			HealthPotion copy = new HealthPotion(name);
			copy.name = name;
			copy.healthRestore = healthRestore;
			return copy;
		}
		
		/** returns name, count, itemtype, healthRestore. split at ITEMINFO */
		public String getSave() {
			String result = super.getSave() + "<ITEMINFO>healthpotion<ITEMINFO>" + healthRestore;
			return result;
		}
	}
	
	
}
